<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>收银员登陆</title>
		<link rel="stylesheet" href="dist/css/layui.css" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<link rel="stylesheet" href="css/shouy.css" />
	</head>

	<body>
		<div class="bagimg"><img src="img/banner.jpg"></div>
		<div class="login_conbox">
			<div class="login_content">
				<div class="login_con">
					<div class="log_header">
						<div class="log_logo"><img src="img/logo-ma.png"></div>
						<p id="app_name"></p>
					</div>
					<div class="log_body">
						<form class="layui-form" action="">
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="iconfont icon-yonghuming"></span></label>
								<div class="layui-input-block">
									<input type="text" id="phone" name="phone" required lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="iconfont icon-mima"></span></label>
								<div class="layui-input-block">
									<input type="password" id="pwd" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
								</div>
							</div>
						</form>
						<a href="#" class="layui-btn">确定</a>
					</div>
					<div class="fwnum">服务电话：<em id="app_mobile">400-1138-290</em></div>
				</div>
			</div>
		</div>
		<script src="dist/json2.js"></script>
		<script type="text/javascript" src="dist/jquery-1.11.0.min.js"></script>
		<script src="dist/layui.js"></script>
		<script src="dist/layui.all.js"></script>
		<script type="text/javascript" src="js/app.js"></script>
	</body>
	<script>
		$('.layui-btn').click(function() {
		var phone = $("#phone").val();
		var pwd = $("#pwd").val();
		if(phone == '') {
			layer.msg('请输入用户账号');
			return;
		}
		if($.trim(pwd) == '') {
			layer.msg('登录密码不能为空');
			return;
		}
		//写入数据库
		$.ajax({
			//请求的url
			//注意，如果我们使用路由器的情况下，我们需要设置一下本地服务器的ip地址
			url:APP.api_url+"index/login",
			type:"POST",
			//请求的过程中传递过去的参数 json
			data: {
				mobile	: phone,
				password		: pwd,
				app_id	:APP.app_id,
				time:Date.parse( new Date())
			},
			//成功了的回调，并且带有返回值
			success: function(data) {
				layer.msg(data.msg, {time: 1000}, 
					function() {
						if(data.code == 200) {
							localStorage.setItem('member', JSON.stringify(data.member));
							location.href='index.html';
						}
				});
			}
		})
	});
	
	</script>
</html>